﻿using System.Linq;
using System.Collections.Generic;
using NHibernate;
using TSites.Core.Domain;
using System.Collections;

namespace TSites.Core.Repository
{
	public interface IRepository<T, IdT> where T : class
	{
		// Get methods
		T GetByID(IdT id);
		T GetByID(IdT id, LockMode lckMode);
		T GetByCriteria(ICriteria criteria);
		IList<T> GetList();
		IList<T> GetList(ICriteria criteria, bool asc, params string[] orderByCol);
		IList GetList(ICriteria criteria, int pageIndex, int pageSize, out int totalItems);
		// LINQ supported
		IQueryable<T> GetByLinq();

		// Insert methods
		IdT Insert(T entity);
		void Insert(List<T> list);

		// Save method
		void Update(T entity);
		void InsertOrUpdate(T entity);
		
		// Delete
		void Delete(T entity);

		// Stored procedures
		T ExecuteSingleQuery(string spName, params object[] parameters);
		IList<T> ExecuteQuery(string spName, params object[] parameters);
		int ExecuteNonQuery(string spName, params object[] parameters);
	}
}
